<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../vue.js"></script>
  <script src="./vue-router.js"></script>
</head>

<body>

  <div id="app">
    <router-link tag="button" to="/position/1">前端开发</router-link>
    <router-link tag="button" to="/search">搜索</router-link>
    <router-link tag="button" to="/profile">我的</router-link>
    <router-view></router-view>




  </div>


  <script>

    var position = {
      // props: ['abc','city'],
      // template: `<div>position:{{abc}}-{{city}}</div>`
      props: ['name','age'],
      template: `<div>position:{{name}}-{{age}}</div>`
    }
    var search = { template: `<div>search</div>` }
    var profile = { template: `<div>profile</div>` }

    var routes = [
      {
        path: '/position/:abc',
        component: position,
        // props: true
        // props:{
        //   abc:33,
        //   city:'taiyuan'
        // }
        props:()=>{
          return {
            name:"admin",
            age:20
          }
        }
      },
      {
        path: '/search',
        component: search
      },
      {
        path: '/profile',
        component: profile
      }
    ]

    var router = new VueRouter({
      mode: 'history',
      routes
    })

    var vm = new Vue({
      router
    }).$mount('#app')

  </script>

</body>

</html>